/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package thirdProject;

import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author asculx
 */
public class BFS {

    public BFS() {
    }
    
   
    public List bfsTraversal(int s) {
            LinkedList<Integer> S = new LinkedList<Integer>(); 
            boolean[] inS = new boolean[S.size()];
            LinkedList<Integer> Q = new LinkedList<Integer>(); //Queue
            S.add(s); 
            inS[s - 1] = true; 
//            Q.addAll(getNeighbors(s)); //Put while (!Q.isEmpty()) {
            while (!Q.isEmpty()) {
                int v = Q.remove(0); //Get 
                if (!inS[v - 1]) {
                    S.add(v); inS[v - 1] = true;
//                    Q.addAll(getNeighbors(v)); //Put
                }
            }
        return S; 
    }    
}
